
#include "MyCameraWindow.h"

MyCameraWindow::MyCameraWindow(CvCapture *cam, QWidget *parent) : QWidget(parent) {

    camera = cam;
    QVBoxLayout *layout = new QVBoxLayout;
    cvwidget = new QOpenCVWidget(this);
    layout->addWidget(cvwidget);
    setLayout(layout);

    Lable_save_bill =new QLabel("waiting push Save Bill Face",this);
    Button_saveBill =new QPushButton("save Bill face",this);


     QObject::connect(Button_saveBill, SIGNAL(clicked()),this, SLOT(save_bill()));
        cvwidget->button_cv_parent = Button_saveBill;



    startTimer(10);  // 0.1-second timer
 }
void MyCameraWindow::save_bill()
{
    Button_saveBill->setDisabled(true);

    qDebug("cliked");
}

void MyCameraWindow::timerEvent(QTimerEvent*) {

    IplImage *image=cvQueryFrame(camera);
    if(this->width() != image->width || this->height() != image->height+Button_height*2)
    {
        resize(image->width,image->height+Button_height*2);
        Lable_save_bill->setGeometry(10,image->height,Label_witdh,Button_height);
        Button_saveBill->setGeometry(10,image->height+Button_height,Label_witdh,Button_height);
    }
   /* if( ! Button_saveBill->isEnabled())
    {
        qDebug("is enable");
        QPixmap screenshot;
        screenshot = QPixmap::grabWidget(cvwidget,0,0,cvwidget->width(),cvwidget->height());
        screenshot.save("test.png","PNG");
         Button_saveBill->setDisabled(false);

    }
    */



    cvwidget->putImage(image);
    Lable_save_bill->show();
    Button_saveBill->show();
}

